<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<script type="text/javascript">
	//初始化表单验证
	$("#editForm").validate({
		 rules:{
			 active_title:{
				 maxlength:20
			 },
			publish:{
				digits:true
			},
			start:{
				dateISO : true
			},
			stop:{
				dateISO : true
			}
		},
		 
		messages : {
			active_title : {
				required : "请输入活动标题"
			},
			start : {
				required : "请输入开始时间"
			},
			stop : {
				required : "请输入结束时间"
			}

		},
		submitHandler : function(form) {
			$(form).ajaxSubmit({
				success : function(data) {
					switch (data.flag) {
					case -1:
						Kit.alert("网络繁忙...，请重试");
						return;
					case 1:
						Kit.alert("数据异常");
						return;
					case 2:
						Kit.alert("标题不能为空");
						return;
					case 3:
						Kit.alert("标题长度不能超过20");
						return;
					case 4:
						Kit.alert("开始时间不能大于结束时间");
						return;
					case 0:
						dataPaginator.loadPage(1);
						editDialog.close();
					}
				}
			});
		}
	});
/* 验证输入的日期先后顺序 */
	 $("#startdate").datetimepicker({
		format : 'yyyy-mm-dd',
		language : 'zh-CN',
		weekStart : 1,
		todayBtn : 1,//显示‘今日’按钮
		autoclose : 1,
		todayHighlight : 1,
		startView : 2,
		minView : 2, //Number, String. 默认值：0, 'hour'，日期时间选择器所能够提供的最精确的时间选择视图。
		forceParse :0,
		endDate:$("#stopdate").val(),
		/* endDate : new Date(), */
	}).on('changeDate', function(ev) {
		var starttime = $("#startdate").val();
		$("#stopdate").datetimepicker('setStartDate', starttime);
		$("#startdate").datetimepicker('hide');
	});

	$("#stopdate").datetimepicker({
		format : 'yyyy-mm-dd',
		language : 'zh-CN',
		weekStart : 1,
		todayBtn : 1,//显示‘今日’按钮
		autoclose : 1,
		todayHighlight : 1,
		startView : 2,
		minView : 2, //Number, String. 默认值：0, 'hour'，日期时间选择器所能够提供的最精确的时间选择视图。
		forceParse : 0,
		startDate:$("#startdate").val(),
		/*  endDate : new Date(),  */
	}).on('changeDate', function(ev) {
		var starttime = $("#startdate").val();
		var endtime = $("#stopdate").val();
		$("#startdate").datetimepicker('setEndDate', endtime);
		$("#stopdate").datetimepicker('hide');
	}); 
	
</script>
<form id="editForm" action="${BASE_PATH}/spike/list/doEdit"
	method="post" class="form-horizontal">
	<div class="form-group">
		<label class="col-lg-2 control-label">编辑活动</label>
		<div class="col-lg-9">
			<input type="text" name="active_title" value="${object.active_title}"
				class="form-control width130" required maxlength="50">
		</div>
	</div>

	 <div class="form-group">
		<label class="col-lg-2 control-label">活动状态</label>
		<div class="col-lg-9">
			<input type="text" name="active_state" value="${object.active_state}"
				class="form-control width130" maxlength="50">
		</div>
	</div>
	<div class="form-group">
		<label class="col-lg-2 control-label">开始时间</label>
		<div class="col-lg-9">
			<input type="text" name="start" id="startdate"
				value="${object.start }"
				class="form-control search-input width130 datetimepicker"
				data-format="yyyy-mm-dd" maxlength="20">
		</div>
	</div>
	<div class="form-group">
		<label class="col-lg-2 control-label">结束时间</label>
		<div class="col-lg-9">
			<input type="text" name="stop" id="stopdate" value="${object.stop }"
				class="form-control search-input width130 datetimepicker"
				data-format="yyyy-mm-dd" maxlength="20">
		</div>
	</div>
	<div class="form-group">
		<label class="col-lg-2 control-label">上架/下架</label>
		<div class="col-lg-9">
			<select name="publish" class="selectpicker form-control">

				<option value="1"
					<c:if test="${object.publish==1}">data-dropdown-selected="true"</c:if>>上架</option>
				<option value="0" <c:if test="${object.publish==0}">selected</c:if>>下架</option>
			</select>
		</div>
	</div>
	<div class="row">
		<div class="col-lg-6">
			<button class="btn btn-primary col-sm-3 pull-right" type="submit"
				autocomplete="off">提交</button>
		</div>
		<div class="col-lg-6">
			<button class="btn btn-default col-sm-3 pull-left" type="button"
				onclick="javascript:editDialog.close();" autocomplete="off">取消</button>
		</div>
	</div>
	<input type="hidden" name="listid" value="${object.id}" />

</form>